/* Replication for Testotorene 
Data used is NHANES 2011-2012. 

Source: http://wwwn.cdc.gov/Nchs/Nhanes/Search/nhanes11_12.aspx


Download

Demographic Data from: http://wwwn.cdc.gov/nchs/nhanes/2011-2012/DEMO_G.XPT
Occupation data http://wwwn.cdc.gov/nchs/nhanes/2011-2012/OCQ_G.XPT
Total Testosterone data from: http://wwwn.cdc.gov/nchs/nhanes/2011-2012/TST_G.XPT
Height Weight data: http://wwwn.cdc.gov/nchs/nhanes/2011-2012/WHQ_G.XPT
Health Status: http://wwwn.cdc.gov/nchs/nhanes/2011-2012/HSQ_G.XPT
Red Blood cell: http://wwwn.cdc.gov/nchs/nhanes/2011-2012/CBC_G.XPT
Dietary Intake: http://wwwn.cdc.gov/nchs/nhanes/2011-2012/DR1TOT_G.XPT
*/

*Import downloaded files that are in SAS format to Stata

import sasxport "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\DEMO_G.XPT"
save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\Demo_G.dta", replace

import sasxport "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\HSQ_G.XPT"
save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\HSQ_G.dta", replace

import sasxport "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\OCQ_G.XPT"
save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\OCQ_G.dta", replace

import sasxport "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\TST_G.XPT"
save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\TST_G.dta", replace

import sasxport "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\WHQ_G.XPT"
save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\WHQ_G.dta", replace

import sasxport "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\CBC_G.XPT"
save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\CBC_G.dta", replace

import sasxport "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\DR1TOT_G.XPT"
save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\DR1TOT_G.dta", replace


*Start merging with Demographic data using the following commands:

use "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\Demo_G.dta", clear
save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Study 1 -- NHANES 2011_2012 Merged Data File.dta", replace

merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\HSQ_G.dta", generate(_merge_HSQ_G)

merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\OCQ_G.dta", generate(_merge_OCQ_G)

merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\TST_G.dta", generate(_merge_TST_G)

merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\WHQ_G.dta", generate(_merge_WHQ_G)

merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\CBC_G.dta", generate(_merge_CBC_G)

merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\DR1TOT_G.dta", generate(_merge_DR1TOT_G)

save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Study 1 -- NHANES 2011_2012 Merged Data File.dta", replace


/*Results from merging

. merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\HSQ_G.dta"
> , generate(_merge_HSQ_G)

    Result                           # of obs.
    -----------------------------------------
    not matched                           800
        from master                       800  (_merge_HSQ_G==1)
        from using                          0  (_merge_HSQ_G==2)

    matched                             8,956  (_merge_HSQ_G==3)
    -----------------------------------------

. 
. 
. 
. merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\OCQ_G.dta"
> , generate(_merge_OCQ_G)

    Result                           # of obs.
    -----------------------------------------
    not matched                         3,581
        from master                     3,581  (_merge_OCQ_G==1)
        from using                          0  (_merge_OCQ_G==2)

    matched                             6,175  (_merge_OCQ_G==3)
    -----------------------------------------

. 
. 
. 
. merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\TST_G.dta"
> , generate(_merge_TST_G)

    Result                           # of obs.
    -----------------------------------------
    not matched                         1,935
        from master                     1,935  (_merge_TST_G==1)
        from using                          0  (_merge_TST_G==2)

    matched                             7,821  (_merge_TST_G==3)
    -----------------------------------------

. 
. 
. 
. merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\WHQ_G.dta"
> , generate(_merge_WHQ_G)

    Result                           # of obs.
    -----------------------------------------
    not matched                         3,581
        from master                     3,581  (_merge_WHQ_G==1)
        from using                          0  (_merge_WHQ_G==2)

    matched                             6,175  (_merge_WHQ_G==3)
    -----------------------------------------

. 
. 
. 
. merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\CBC_G.dta"
> , generate(_merge_CBC_G)

    Result                           # of obs.
    -----------------------------------------
    not matched                           800
        from master                       800  (_merge_CBC_G==1)
        from using                          0  (_merge_CBC_G==2)

    matched                             8,956  (_merge_CBC_G==3)
    -----------------------------------------

. 
. 
. 
. merge 1:1 seqn using "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Raw files from CDC\DR1TOT_G.d
> ta", generate(_merge_DR1TOT_G)

    Result                           # of obs.
    -----------------------------------------
    not matched                           418
        from master                       418  (_merge_DR1TOT_G==1)
        from using                          0  (_merge_DR1TOT_G==2)

    matched                             9,338  (_merge_DR1TOT_G==3)
    -----------------------------------------

*/

/*Coding for self-employed*/
generate self_employed = ocq260
tab self_employed
recode self_employed (1/4=0) (6=0) (77=.) (99=.) (5=1)
tab self_employed

/*Height*/
recode whd010 (7777=.) (9999=.)
recode dmdmartl (77=.) (99=.)

*Generate race dummy
tab ridreth3, gen(race)

*Recode education missing values
recode dmdeduc2 (7/9=.)

* drop individuals below 18 years at the time of screening 
recode ridageyr (0=.)
drop if ridageyr < 18

save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Study 1 -- NHANES 2011_2012 Merged Data File.dta", replace

*Standardized testosterone values
egen z_lbxtst = std(lbxtst)
egen z_female_testo = std(lbxtst) if riagendr == 2
egen z_male_testo = std(lbxtst) if riagendr == 1
egen z_testo = rowtotal(z_female_testo  z_male_testo)

*Generate predicted values for 2SLS, seperately for males and females

regress z_testo dr1tzin lbxrbcsi lbxhct if riagendr == 1
predict predictedz_testo_ZiRbHc_Male
regress z_testo dr1tzin lbxrbcsi lbxhct if riagendr == 2
predict predictedz_testo_ZiRbHc_Female

** Table 1 Desccriptives and Correlations table
*pwcorr and corr have identical results
pwcorr self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 riagendr z_lbxtst, casewise star(0.05)
corr self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 riagendr z_lbxtst
tabstat self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 riagendr z_lbxtst, casewise col(stat) stat(mean sd min max)

*Table 2

logit self_employed predictedz_testo_ZiRbHc_Male ridageyr dmdeduc2 dmdmartl indfmpir hsd010  race1-race6  [pweight = wtmec2yr] if riagendr == 1
outreg2 using Study1Logit.xls, append tstat alpha(0.001, 0.01,0.05,0.10) symbol(***,**,*, +) addstat("Chi-square", e(chi2), "p-value", e(p))

logit self_employed predictedz_testo_ZiRbHc_Female ridageyr dmdeduc2 dmdmartl indfmpir hsd010  race1-race6 [pweight = wtmec2yr] if riagendr == 2
outreg2 using Study1Logit.xls, replace tstat alpha(0.001, 0.01,0.05,0.10) symbol(***,**,*, +) addstat("Chi-square", e(chi2), "p-value", e(p))

ivreg2 self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 (z_female_testo = dr1tzin lbxrbcsi lbxhct) if riagendr == 2, endogtest(z_female_testo) ffirst orthog()
ivreg2 self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 (z_male_testo = dr1tzin lbxrbcsi lbxhct) if riagendr == 1, endogtest(z_male_testo) ffirst orthog()

save "C:\Users\ppatel\Desktop\MS RR2 Final Replication Code\Study 1 -- NHANES\Study 1 -- NHANES 2011_2012 Merged Data File.dta", replace


/*Raw Output


. corr self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 riagendr z_lbxtst
(obs=2,157)

             | self_e~d ridageyr dmdeduc2 dmdmartl indfmpir   hsd010    race1    race2    race3    race4    race5    race6
-------------+------------------------------------------------------------------------------------------------------------
self_emplo~d |   1.0000
    ridageyr |   0.1902   1.0000
    dmdeduc2 |  -0.0144  -0.0770   1.0000
    dmdmartl |  -0.0625  -0.3530  -0.0438   1.0000
    indfmpir |   0.0142   0.1737   0.4547  -0.2100   1.0000
      hsd010 |  -0.0508   0.0708  -0.2835   0.0396  -0.2635   1.0000
       race1 |  -0.0241  -0.0429  -0.2844  -0.0131  -0.1418   0.1367   1.0000
       race2 |  -0.0299   0.0003  -0.1350   0.0503  -0.0859   0.0643  -0.1180   1.0000
       race3 |   0.0792   0.0159   0.1468  -0.0558   0.0958  -0.1493  -0.2780  -0.2608   1.0000
       race4 |  -0.0490   0.0544   0.0008   0.0959  -0.0369   0.0617  -0.1989  -0.1866  -0.4396   1.0000
       race5 |  -0.0077  -0.0293   0.1566  -0.0777   0.1239  -0.0469  -0.1417  -0.1330  -0.3132  -0.2241   1.0000
       race6 |   0.0095  -0.0427   0.0255   0.0114  -0.0177   0.0001  -0.0635  -0.0596  -0.1404  -0.1004  -0.0715   1.0000
    riagendr |  -0.0868  -0.0185   0.1073   0.0456   0.0041   0.0395  -0.0432  -0.0062  -0.0298   0.0910  -0.0179  -0.0157
    z_lbxtst |   0.0722  -0.0332  -0.0963   0.0126  -0.0157  -0.0925   0.0380  -0.0001   0.0320  -0.0630  -0.0006  -0.0023

             | riagendr z_lbxtst
-------------+------------------
    riagendr |   1.0000
    z_lbxtst |  -0.8363   1.0000


. 
. tabstat self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 riagendr z_lbxtst, casewise col(stat) stat(mea
> n sd min max)

    variable |      mean        sd       min       max
-------------+----------------------------------------
self_emplo~d |  .1172925  .3218432         0         1
    ridageyr |  43.20213  14.12471        20        80
    dmdeduc2 |  3.789059  1.165566         1         5
    dmdmartl |  2.681966  1.950433         1         6
    indfmpir |  2.876592  1.676307         0         5
      hsd010 |  2.581827  .9129067         1         5
       race1 |  .1117293  .3151061         0         1
       race2 |  .0996755  .2996363         0         1
       race3 |  .3806212  .4856522         0         1
       race4 |  .2392211  .4267069         0         1
       race5 |  .1376912  .3446555         0         1
       race6 |  .0310617  .1735246         0         1
    riagendr |  1.446453  .4972398         1         2
    z_lbxtst |  .0966883  .9779551 -.9088616  3.828825
------------------------------------------------------

. 
. 
. 
. *Table 2

. 
. 
. 
. logit self_employed predictedz_testo_ZiRbHc_Male ridageyr dmdeduc2 dmdmartl indfmpir hsd010  race1-race6  [pweight = wtmec2
> yr] if riagendr == 1

note: race6 omitted because of collinearity
Iteration 0:   log pseudolikelihood =  -26440199  
Iteration 1:   log pseudolikelihood =  -24413665  
Iteration 2:   log pseudolikelihood =  -24277877  
Iteration 3:   log pseudolikelihood =  -24277292  
Iteration 4:   log pseudolikelihood =  -24277292  

Logistic regression                             Number of obs     =      1,178
                                                Wald chi2(11)     =      49.87
                                                Prob > chi2       =     0.0000
Log pseudolikelihood =  -24277292               Pseudo R2         =     0.0818

----------------------------------------------------------------------------------------------
                             |               Robust
               self_employed |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-----------------------------+----------------------------------------------------------------
predictedz_testo_ZiRbHc_Male |   1.443592   .7732814     1.87   0.062    -.0720121    2.959195
                    ridageyr |   .0503203   .0091358     5.51   0.000     .0324144    .0682262
                    dmdeduc2 |   .0491197   .1269447     0.39   0.699    -.1996872    .2979267
                    dmdmartl |   .0571859   .0665054     0.86   0.390    -.0731622    .1875341
                    indfmpir |   -.081648   .0913605    -0.89   0.371    -.2607114    .0974154
                      hsd010 |  -.1143852   .1442084    -0.79   0.428    -.3970285    .1682581
                       race1 |   .0216976   .6312761     0.03   0.973    -1.215581    1.258976
                       race2 |   .4409062   .6313583     0.70   0.485    -.7965334    1.678346
                       race3 |   .8561622   .5414938     1.58   0.114    -.2051461     1.91747
                       race4 |   .3212194   .5677948     0.57   0.572    -.7916381    1.434077
                       race5 |   .6973322   .5844294     1.19   0.233    -.4481284    1.842793
                       race6 |          0  (omitted)
                       _cons |  -4.623993   1.020694    -4.53   0.000    -6.624516    -2.62347
----------------------------------------------------------------------------------------------

. 
. outreg2 using Study1Logit.xls, append tstat alpha(0.001, 0.01,0.05,0.10) symbol(***,**,*, +) addstat("Chi-square", e(chi2),
>  "p-value", e(p))
Study1Logit.xls
dir : seeout

. 
. 
. 
. logit self_employed predictedz_testo_ZiRbHc_Female ridageyr dmdeduc2 dmdmartl indfmpir hsd010  race1-race6 [pweight = wtmec
> 2yr] if riagendr == 2

note: race6 omitted because of collinearity
Iteration 0:   log pseudolikelihood =  -14545068  
Iteration 1:   log pseudolikelihood =  -14011981  
Iteration 2:   log pseudolikelihood =  -13968454  
Iteration 3:   log pseudolikelihood =  -13967676  
Iteration 4:   log pseudolikelihood =  -13967673  
Iteration 5:   log pseudolikelihood =  -13967673  

Logistic regression                             Number of obs     =        968
                                                Wald chi2(11)     =      19.19
                                                Prob > chi2       =     0.0577
Log pseudolikelihood =  -13967673               Pseudo R2         =     0.0397

------------------------------------------------------------------------------------------------
                               |               Robust
                 self_employed |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------------------------+----------------------------------------------------------------
predictedz_testo_ZiRbHc_Female |   2.822671   4.952911     0.57   0.569    -6.884856     12.5302
                      ridageyr |   .0267025   .0126807     2.11   0.035     .0018488    .0515562
                      dmdeduc2 |   .0898869   .1971989     0.46   0.649    -.2966159    .4763898
                      dmdmartl |  -.0947514   .1003331    -0.94   0.345    -.2914008    .1018979
                      indfmpir |  -.1564725   .0993143    -1.58   0.115    -.3511249    .0381799
                        hsd010 |  -.3441893   .1994913    -1.73   0.084    -.7351851    .0468065
                         race1 |    .462081   .9621135     0.48   0.631    -1.423627    2.347789
                         race2 |  -1.349769    1.07897    -1.25   0.211    -3.464511    .7649735
                         race3 |  -.0318553   .9388177    -0.03   0.973    -1.871904    1.808194
                         race4 |  -.1106028   .9401463    -0.12   0.906    -1.953256     1.73205
                         race5 |  -.0802171   .9802779    -0.08   0.935    -2.001526    1.841092
                         race6 |          0  (omitted)
                         _cons |  -2.396005   1.706557    -1.40   0.160    -5.740795    .9487845
------------------------------------------------------------------------------------------------

. 
. outreg2 using Study1Logit.xls, replace tstat alpha(0.001, 0.01,0.05,0.10) symbol(***,**,*, +) addstat("Chi-square", e(chi2)
> , "p-value", e(p))
Study1Logit.xls
dir : seeout

. 
. 
. 
. ivreg2 self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 (z_female_testo = dr1tzin lbxrbcsi lbxhct) if r
> iagendr == 2, endogtest(z_female_testo) ffirst orthog()
Warning - collinearities detected
Vars dropped:       race6


Summary results for first-stage regressions
-------------------------------------------

                                           (Underid)            (Weak id)
Variable     | F(  3,   912)  P-val | SW Chi-sq(  3) P-val | SW F(  3,   912)
z_female_tes |       0.95    0.4141 |        2.90   0.4066 |        0.95

Stock-Yogo weak ID F test critical values for single endogenous regressor:
                                    5% maximal IV relative bias    13.91
                                   10% maximal IV relative bias     9.08
                                   20% maximal IV relative bias     6.46
                                   30% maximal IV relative bias     5.39
                                   10% maximal IV size             22.30
                                   15% maximal IV size             12.83
                                   20% maximal IV size              9.54
                                   25% maximal IV size              7.80
Source: Stock-Yogo (2005).  Reproduced by permission.
NB: Critical values are for Sanderson-Windmeijer F statistic.

Underidentification test
Ho: matrix of reduced form coefficients has rank=K1-1 (underidentified)
Ha: matrix has rank=K1 (identified)
Anderson canon. corr. LM statistic       Chi-sq(3)=2.90     P-val=0.4081

Weak identification test
Ho: equation is weakly identified
Cragg-Donald Wald F statistic                                       0.95

Stock-Yogo weak ID test critical values for K1=1 and L1=3:
                                    5% maximal IV relative bias    13.91
                                   10% maximal IV relative bias     9.08
                                   20% maximal IV relative bias     6.46
                                   30% maximal IV relative bias     5.39
                                   10% maximal IV size             22.30
                                   15% maximal IV size             12.83
                                   20% maximal IV size              9.54
                                   25% maximal IV size              7.80
Source: Stock-Yogo (2005).  Reproduced by permission.

Weak-instrument-robust inference
Tests of joint significance of endogenous regressors B1 in main equation
Ho: B1=0 and orthogonality conditions are valid
Anderson-Rubin Wald test           F(3,912)=       0.63     P-val=0.5971
Anderson-Rubin Wald test           Chi-sq(3)=      1.91     P-val=0.5907
Stock-Wright LM S statistic        Chi-sq(3)=      1.91     P-val=0.5915

Number of observations               N  =        926
Number of regressors                 K  =         12
Number of endogenous regressors      K1 =          1
Number of instruments                L  =         14
Number of excluded instruments       L1 =          3

IV (2SLS) estimation
--------------------

Estimates efficient for homoskedasticity only
Statistics consistent for homoskedasticity only

                                                      Number of obs =      926
                                                      F( 11,   914) =     1.99
                                                      Prob > F      =   0.0261
Total (centered) SS     =  70.59719222                Centered R2   =  -0.2591
Total (uncentered) SS   =           77                Uncentered R2 =  -0.1544
Residual SS             =  88.88857204                Root MSE      =    .3098

--------------------------------------------------------------------------------
 self_employed |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
---------------+----------------------------------------------------------------
z_female_testo |   .1444005   .1716901     0.84   0.400     -.192106     .480907
      ridageyr |   .0058061   .0042401     1.37   0.171    -.0025042    .0141165
      dmdeduc2 |  -.0025302    .013571    -0.19   0.852    -.0291288    .0240684
      dmdmartl |    .003903   .0100147     0.39   0.697    -.0157253    .0235314
      indfmpir |  -.0124119   .0076681    -1.62   0.106    -.0274411    .0026173
        hsd010 |  -.0266988   .0121704    -2.19   0.028    -.0505524   -.0028453
         race1 |   .0416246     .07268     0.57   0.567    -.1008256    .1840749
         race2 |  -.0793079   .0742032    -1.07   0.285    -.2247435    .0661276
         race3 |  -.0153102   .0699164    -0.22   0.827    -.1523438    .1217234
         race4 |  -.0491989    .072887    -0.68   0.500    -.1920547     .093657
         race5 |   .0067957   .0676156     0.10   0.920    -.1257284    .1393199
         race6 |          0  (omitted)
         _cons |  -.0439614   .2336185    -0.19   0.851    -.5018452    .4139225
--------------------------------------------------------------------------------
Underidentification test (Anderson canon. corr. LM statistic):           2.895
                                                   Chi-sq(3) P-val =    0.4081
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic):                0.953
Stock-Yogo weak ID test critical values:  5% maximal IV relative bias    13.91
                                         10% maximal IV relative bias     9.08
                                         20% maximal IV relative bias     6.46
                                         30% maximal IV relative bias     5.39
                                         10% maximal IV size             22.30
                                         15% maximal IV size             12.83
                                         20% maximal IV size              9.54
                                         25% maximal IV size              7.80
Source: Stock-Yogo (2005).  Reproduced by permission.
------------------------------------------------------------------------------
Sargan statistic (overidentification test of all instruments):           0.764
                                                   Chi-sq(2) P-val =    0.6824
-endog- option:
Endogeneity test of endogenous regressors:                               0.864
                                                   Chi-sq(1) P-val =    0.3527
Regressors tested:    z_female_testo
------------------------------------------------------------------------------
Instrumented:         z_female_testo
Included instruments: ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1 race2
                      race3 race4 race5
Excluded instruments: dr1tzinc lbxrbcsi lbxhct
Dropped collinear:    race6
------------------------------------------------------------------------------

. 
. ivreg2 self_employed ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1-race6 (z_male_testo = dr1tzin lbxrbcsi lbxhct) if ria
> gendr == 1, endogtest(z_male_testo) ffirst orthog()
Warning - collinearities detected
Vars dropped:       race6


Summary results for first-stage regressions
-------------------------------------------

                                           (Underid)            (Weak id)
Variable     | F(  3,  1140)  P-val | SW Chi-sq(  3) P-val | SW F(  3,  1140)
z_male_testo |      13.03    0.0000 |       39.57   0.0000 |       13.03

Stock-Yogo weak ID F test critical values for single endogenous regressor:
                                    5% maximal IV relative bias    13.91
                                   10% maximal IV relative bias     9.08
                                   20% maximal IV relative bias     6.46
                                   30% maximal IV relative bias     5.39
                                   10% maximal IV size             22.30
                                   15% maximal IV size             12.83
                                   20% maximal IV size              9.54
                                   25% maximal IV size              7.80
Source: Stock-Yogo (2005).  Reproduced by permission.
NB: Critical values are for Sanderson-Windmeijer F statistic.

Underidentification test
Ho: matrix of reduced form coefficients has rank=K1-1 (underidentified)
Ha: matrix has rank=K1 (identified)
Anderson canon. corr. LM statistic       Chi-sq(3)=38.26    P-val=0.0000

Weak identification test
Ho: equation is weakly identified
Cragg-Donald Wald F statistic                                      13.03

Stock-Yogo weak ID test critical values for K1=1 and L1=3:
                                    5% maximal IV relative bias    13.91
                                   10% maximal IV relative bias     9.08
                                   20% maximal IV relative bias     6.46
                                   30% maximal IV relative bias     5.39
                                   10% maximal IV size             22.30
                                   15% maximal IV size             12.83
                                   20% maximal IV size              9.54
                                   25% maximal IV size              7.80
Source: Stock-Yogo (2005).  Reproduced by permission.

Weak-instrument-robust inference
Tests of joint significance of endogenous regressors B1 in main equation
Ho: B1=0 and orthogonality conditions are valid
Anderson-Rubin Wald test           F(3,1140)=      1.08     P-val=0.3563
Anderson-Rubin Wald test           Chi-sq(3)=      3.28     P-val=0.3502
Stock-Wright LM S statistic        Chi-sq(3)=      3.27     P-val=0.3515

Number of observations               N  =       1154
Number of regressors                 K  =         12
Number of endogenous regressors      K1 =          1
Number of instruments                L  =         14
Number of excluded instruments       L1 =          3

IV (2SLS) estimation
--------------------

Estimates efficient for homoskedasticity only
Statistics consistent for homoskedasticity only

                                                      Number of obs =     1154
                                                      F( 11,  1142) =     9.05
                                                      Prob > F      =   0.0000
Total (centered) SS     =  140.6932409                Centered R2   =   0.0222
Total (uncentered) SS   =          164                Uncentered R2 =   0.1612
Residual SS             =  137.5682571                Root MSE      =    .3453

------------------------------------------------------------------------------
self_emplo~d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
z_male_testo |   .1020856   .0637959     1.60   0.110     -.022952    .2271231
    ridageyr |    .007261    .000813     8.93   0.000     .0056675    .0088545
    dmdeduc2 |   .0055492    .010544     0.53   0.599    -.0151166     .026215
    dmdmartl |   .0045367   .0061987     0.73   0.464    -.0076125     .016686
    indfmpir |  -.0086684   .0072663    -1.19   0.233    -.0229102    .0055734
      hsd010 |  -.0024033   .0157182    -0.15   0.878    -.0332105    .0284039
       race1 |  -.1145598    .064495    -1.78   0.076    -.2409677    .0118482
       race2 |  -.0947396   .0649201    -1.46   0.144    -.2219806    .0325014
       race3 |  -.0306111   .0587621    -0.52   0.602    -.1457828    .0845605
       race4 |  -.1150703   .0617203    -1.86   0.062    -.2360399    .0058992
       race5 |  -.0575026   .0623605    -0.92   0.356     -.179727    .0647218
       race6 |          0  (omitted)
       _cons |  -.1077526   .0917389    -1.17   0.240    -.2875574    .0720523
------------------------------------------------------------------------------
Underidentification test (Anderson canon. corr. LM statistic):          38.258
                                                   Chi-sq(3) P-val =    0.0000
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic):               13.030
Stock-Yogo weak ID test critical values:  5% maximal IV relative bias    13.91
                                         10% maximal IV relative bias     9.08
                                         20% maximal IV relative bias     6.46
                                         30% maximal IV relative bias     5.39
                                         10% maximal IV size             22.30
                                         15% maximal IV size             12.83
                                         20% maximal IV size              9.54
                                         25% maximal IV size              7.80
Source: Stock-Yogo (2005).  Reproduced by permission.
------------------------------------------------------------------------------
Sargan statistic (overidentification test of all instruments):           0.508
                                                   Chi-sq(2) P-val =    0.7757
-endog- option:
Endogeneity test of endogenous regressors:                               2.630
                                                   Chi-sq(1) P-val =    0.1049
Regressors tested:    z_male_testo
------------------------------------------------------------------------------
Instrumented:         z_male_testo
Included instruments: ridageyr dmdeduc2 dmdmartl indfmpir hsd010 race1 race2
                      race3 race4 race5
Excluded instruments: dr1tzinc lbxrbcsi lbxhct
Dropped collinear:    race6
------------------------------------------------------------------------------

. 
*/

